package aigle.bvieillard.gmf.tp2.diagram.part;

import java.util.Collections;
import java.util.List;

import org.eclipse.gef.Tool;
import org.eclipse.gef.palette.PaletteContainer;
import org.eclipse.gef.palette.PaletteGroup;
import org.eclipse.gef.palette.PaletteRoot;
import org.eclipse.gef.palette.ToolEntry;
import org.eclipse.gmf.runtime.diagram.ui.tools.UnspecifiedTypeConnectionTool;
import org.eclipse.gmf.runtime.diagram.ui.tools.UnspecifiedTypeCreationTool;
import org.eclipse.gmf.runtime.emf.type.core.IElementType;

import aigle.bvieillard.gmf.tp2.diagram.providers.Tp2ElementTypes;

/**
 * @generated
 */
public class Tp2PaletteFactory {

	/**
	 * @generated
	 */
	public void fillPalette(PaletteRoot paletteRoot) {
		paletteRoot.add(createTp21Group());
	}

	/**
	 * Creates "tp2" palette tool group
	 * @generated
	 */
	private PaletteContainer createTp21Group() {
		PaletteGroup paletteContainer = new PaletteGroup(
				Messages.Tp21Group_title);
		paletteContainer.setId("createTp21Group"); //$NON-NLS-1$
		paletteContainer.add(createRecette1CreationTool());
		paletteContainer.add(createRecetteOrigineRegionale2CreationTool());
		paletteContainer.add(createIngredient3CreationTool());
		paletteContainer.add(createVin4CreationTool());
		paletteContainer.add(createCompose5CreationTool());
		paletteContainer.add(createLocalisation6CreationTool());
		paletteContainer.add(createBouteille7CreationTool());
		return paletteContainer;
	}

	/**
	 * @generated
	 */
	private ToolEntry createRecette1CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.Recette1CreationTool_title,
				Messages.Recette1CreationTool_desc,
				Collections.singletonList(Tp2ElementTypes.Localisation_2001));
		entry.setId("createRecette1CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(Tp2ElementTypes
				.getImageDescriptor(Tp2ElementTypes.Localisation_2001));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createRecetteOrigineRegionale2CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.RecetteOrigineRegionale2CreationTool_title,
				Messages.RecetteOrigineRegionale2CreationTool_desc,
				Collections.singletonList(Tp2ElementTypes.Recette_2002));
		entry.setId("createRecetteOrigineRegionale2CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(Tp2ElementTypes
				.getImageDescriptor(Tp2ElementTypes.Recette_2002));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createIngredient3CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.Ingredient3CreationTool_title,
				Messages.Ingredient3CreationTool_desc,
				Collections.singletonList(Tp2ElementTypes.Ingredient_2003));
		entry.setId("createIngredient3CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(Tp2ElementTypes
				.getImageDescriptor(Tp2ElementTypes.Ingredient_2003));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createVin4CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.Vin4CreationTool_title,
				Messages.Vin4CreationTool_desc,
				Collections.singletonList(Tp2ElementTypes.Vin_2004));
		entry.setId("createVin4CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(Tp2ElementTypes
				.getImageDescriptor(Tp2ElementTypes.Vin_2004));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createCompose5CreationTool() {
		LinkToolEntry entry = new LinkToolEntry(
				Messages.Compose5CreationTool_title,
				Messages.Compose5CreationTool_desc,
				Collections.singletonList(Tp2ElementTypes.Compose_4001));
		entry.setId("createCompose5CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(Tp2ElementTypes
				.getImageDescriptor(Tp2ElementTypes.Compose_4001));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createLocalisation6CreationTool() {
		ToolEntry entry = new ToolEntry(
				Messages.Localisation6CreationTool_title,
				Messages.Localisation6CreationTool_desc, null, null) {
		};
		entry.setId("createLocalisation6CreationTool"); //$NON-NLS-1$
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createBouteille7CreationTool() {
		LinkToolEntry entry = new LinkToolEntry(
				Messages.Bouteille7CreationTool_title,
				Messages.Bouteille7CreationTool_desc,
				Collections
						.singletonList(Tp2ElementTypes.RecetteOrigineRegionale_4002));
		entry.setId("createBouteille7CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(Tp2ElementTypes
				.getImageDescriptor(Tp2ElementTypes.RecetteOrigineRegionale_4002));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private static class NodeToolEntry extends ToolEntry {

		/**
		 * @generated
		 */
		private final List<IElementType> elementTypes;

		/**
		 * @generated
		 */
		private NodeToolEntry(String title, String description,
				List<IElementType> elementTypes) {
			super(title, description, null, null);
			this.elementTypes = elementTypes;
		}

		/**
		 * @generated
		 */
		public Tool createTool() {
			Tool tool = new UnspecifiedTypeCreationTool(elementTypes);
			tool.setProperties(getToolProperties());
			return tool;
		}
	}

	/**
	 * @generated
	 */
	private static class LinkToolEntry extends ToolEntry {

		/**
		 * @generated
		 */
		private final List<IElementType> relationshipTypes;

		/**
		 * @generated
		 */
		private LinkToolEntry(String title, String description,
				List<IElementType> relationshipTypes) {
			super(title, description, null, null);
			this.relationshipTypes = relationshipTypes;
		}

		/**
		 * @generated
		 */
		public Tool createTool() {
			Tool tool = new UnspecifiedTypeConnectionTool(relationshipTypes);
			tool.setProperties(getToolProperties());
			return tool;
		}
	}
}
